package com.zecan.blog.entity;

import lombok.*;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @ClassName ElasticArticle
 * @Description
 * @date 2022/11/19 16:38
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@Document(indexName = "blog-article",shards = 5)
public class ElasticArticle {
    // 文章id
    @Field(type = FieldType.Integer,name = "article_id")
    private Integer articleId;

    //文章用戶id
    @Field(type = FieldType.Integer, name = "article_author_id")
    private Long articleAuthorId;

    //文章标题   建立索引的时候使用ik_max_word使分词更细， 搜索的时候使用ik_smart 使词粒度更粗，搜索更快
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart", name = "article_title")
    private String articleTitle;

    // 文章展示片段
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart", name = "article_description")
    private String articleDescription;

    //文章创建时间
    @Field(type = FieldType.Text, name = "article_create_time")
    private String articleCreateTime;

    // 文章作者用户名
    @Field(type = FieldType.Text, name = "article_author_name")
    private String articleAuthorName;

    @Field(type = FieldType.Text, name = "article_author_avatar")
    private String articleAuthorAvatar;


    // 文章点赞数量
    @Field(type = FieldType.Integer, name = "article_like_count")
    private Integer articleLikeCount;

    //文章分类
    @Field(type = FieldType.Text, name = "article_classify")
    private String articleClassify;


}
